package ru.compft.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * User: ASUS
 * Date: 21.10.12
 * Time: 11:17
 * Аспект полностью для системной архитектуры
 * Можно логгировать, профилировать любые методы, просто подключив данную библиотеку
 */
@Component
@Aspect
public class SystemArchitecture {

    //   ----------------- Web уровень  ------------------

    /**
     * Любой метод в WEB слое
     */
    @Pointcut("within(ru.compft..web..*)")
    public void inWebLayer() {
    }

    /**
     * Выполнение WEB операции
     */
    @Pointcut("execution(* ru.compft..web.*.*(..))")
    public void webOperation() {
    }

    //   ----------------- Services уровень  ------------------

    /**
     * Любой метод в Services слое
     */
    @Pointcut("within(ru.compft..services..*)")
    public void inServiceLayer() {
    }

    /**
     * A business service is the execution of any method defined on a service
     * interface. This definition assumes that interfaces are placed in the
     * "service" package, and that implementation types are in sub-packages.
     * <p/>
     * If you group service interfaces by functional area (for example,
     * in packages com.xyz.someapp.abc.service and com.xyz.def.service) then
     * the pointcut expression "execution(* com.xyz.someapp..service.*.*(..))"
     * could be used instead.
     * <p/>
     * Alternatively, you can write the expression using the 'bean'
     * PCD, like so "bean(*Service)". (This assumes that you have
     * named your Spring service beans in a consistent fashion.)
     */
    @Pointcut("execution(* ru.compft..services.*.*(..))")
    public void serviceOperation() {
    }

    //   ----------------- DAO уровень  ------------------

    /**
     * Любой метод в DAO слое
     */
    @Pointcut("within(ru.compft..dao..*)")
    public void inDataAccessLayer() {
    }

    /**
     * A data access operation is the execution of any method defined on a
     * dao interface. This definition assumes that interfaces are placed in the
     * "dao" package, and that implementation types are in sub-packages.
     */
    @Pointcut("execution(* ru.compft..dao.*.*(..))")
    public void dataAccessOperation() {
    }

    //   ----------------- BUSINESS уровень  ------------------

    /**
     * Любой метод в BUSINESS слое
     */
    @Pointcut("within(ru.compft..business..*)")
    public void inBusinessLayer() {
    }

    @Pointcut("execution(* ru.compft..business.*.*(..))")
    public void businessOperation() {
    }
}

